<include file="public@header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:url('Finance/index')}">财务管理</a></li>
		</ul>

        <form class="well form-inline margin-top-20" method="post" action="{:url('Finance/index')}">
        	用户名：
            <input type="text" class="form-control" name="user_name" style="width: 250px;" value="" placeholder="用户名">
			交易类型：
			<select class="form-control" name="scene" id="scene" style="width: 200px;">
				<option value="">请选择</option>
	            <option value="1">提现</option>
	            <option value="2">充值</option>
	            <option value="3">退款</option>
	            <option value="4">消费</option>
	            <option value="5">奖励</option>
			</select>
			<span class="btn btn-danger" style="margin-left: 100px;" id="export">导出Excel</span>&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="submit" class="btn btn-primary" value="搜索"  />
            
        </form>
         <div class="linetotal-txt">共有{$total}条记录</div>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th width="260px;">订单号</th>
					<th>用户名</th>
					<th width="130px;">支付方式</th>
					<th width="130px;">类型</th>
					<th width="130px;">金额</th>
					<th width="180px;">交易时间</th>
					<th width="180px;">到账时间</th>
					<th width="120px;">状态</th>
					<th width="180">操作</th>
				</tr>
			</thead>
			<tbody>
                <foreach name="data.data" item="v">
	               <tr>
	               	<td>{$v.order_no}</td>
	               	<td>{$v.mobile}</td>
	               	<td>{$v.payment_type}</td>
	               	<td>{$v.group}</td>
	               	<td>{$v.money}</td>
	               	<td>{$v.create_time}</td>
                    <td>{$v.create_time}</td>
	               	<td>{$v.type}</td>
	               	<td>
                        <if condition="$v['status'] eq -1">
	               		<a class="btn btn-xs btn-primary btn-warning " href="details?id={$v.id}&status={$v.scene}">详情</a>
	               		</if>
                        
	               		<if condition="$v['status'] eq 1">
	            		<span class="btn btn-xs btn-primary btn-warning" onClick="javascript:pass({$v.id});">通过</span>&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<span class="btn btn-xs btn-primary btn-warning" onClick="javascript:reject({$v.id});">拒绝</span>&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<span class="btn btn-xs btn-primary btn-warning" onClick="javascript:anomaly({$v.id});">异常</span>&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a class="btn btn-xs btn-primary btn-warning " href="details?id={$v.id}">详情</a>
	            		</if>

	            		<if condition="$v['status'] eq 2">
	               		<a class="btn btn-xs btn-primary btn-warning " href="details?id={$v.id}">详情</a>
	               		</if>
	               		<if condition="$v['status'] eq 3">
	               		<a class="btn btn-xs btn-primary btn-warning " href="details?id={$v.id}">详情</a>
	               		</if>
	               		<if condition="$v['status'] eq 4">
	               		<span class="btn btn-xs btn-primary btn-warning" onClick="javascript:unfreeze({$v.id});">解冻</span>&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a class="btn btn-xs btn-primary btn-warning " href="details?id={$v.id}">详情</a>
	               		</if>
	               	</td>
	               </tr>
	            </foreach>
			</tbody>
		</table>
		<div class="pagination">{$page}</div>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script type="text/javascript">
    function pass(id){
        del_ok = is_del(1);
  		if(del_ok){
			$.ajax({
	            type: "POST",
	            url: "pass",
	            data: {"id":id},
	            dataType: "json",
	            success: function(data){
	                if(data.code ==1 ){
	                   alert(data.msg);
	                   window.location.href="/admin/finance/index"
	                   return
	                }else{
	                    alert(data.msg);
	                }
	            }        
	        });
		}
    }


    function reject(id){
    	del_ok = is_del(2);
  		if(del_ok){
			$.ajax({
	            type: "POST",
	            url: "reject",
	            data: {"id":id},
	            dataType: "json",
	            success: function(data){
	                if(data.code ==1 ){
	                   alert(data.msg);
	                   window.location.href="/admin/finance/index"
	                   return
	                }else{
	                    alert(data.msg);
	                }
	            }        
	        });
		}
    }


    function anomaly(id){
    	del_ok = is_del(3);
  		if(del_ok){
			$.ajax({
	            type: "POST",
	            url: "anomaly",
	            data: {"id":id},
	            dataType: "json",
	            success: function(data){
	                if(data.code ==1 ){
	                   alert(data.msg);
	                   window.location.href="/admin/finance/index"
	                   return
	                }else{
	                    alert(data.msg);
	                }
	            }        
	        });
		}
    }


    
    function unfreeze(id){
    	del_ok = is_del(4);
  		if(del_ok){
			$.ajax({
	            type: "POST",
	            url: "unfreeze",
	            data: {"id":id},
	            dataType: "json",
	            success: function(data){
	                if(data.code ==1 ){
	                   alert(data.msg);
	                   window.location.href="/admin/finance/index"
	                   return
	                }else{
	                    alert(data.msg);
	                }
	            }        
	        });
		}
    }



    function is_del(type) {
		if(type == 1){
			var msg = "你确定通过吗？"+'\n'+'通过后该订单将不可再更改。';
		}else if(type == 2){
            var msg = '你确定拒绝吗？'+'\n'+'拒绝后提现金额将返还余额。';
		}else if(type == 3){
			var msg = '确定订单异常吗？'+'\n'+'确定后提现金额将被冻结。';
		}else{
			var msg = '你确定解冻吗？'+'\n'+'解冻后将回归未处理状态。';
		}
        if (confirm(msg) == true) {
            return true;
        } else {
            return false;
        }
    }


    $("#export").click(function(){
    	if($("#scene").val() == ''){
    		scene = 0;
    	}else{
    		scene = $("#scene").val();
    	}
        let a = document.createElement('a');
        a.href = 'index?scene='+scene+'&type=1';
        a.click();
        alert('正在导出')
        // window.location.href="/admin/finance/index"
        // return
   })
	</script>
</body>
</html>